package com.qzsoft.zhjd.exp.modules.stressmachine.entity;

import java.time.LocalDateTime;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @ClassName: StressMachineEntity
 * @Description: 压力机
 * @author linhuawei
 * @since 2021-04-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
@TableName("stress_machine")
public class StressMachineEntity {

    @TableId(type = IdType.ASSIGN_UUID)
    private String id;// 数据id
    private String organizationId;// 所属项目
    private String sectionId;// 所属标段项目
    private String sectionName;// 标段名称
    private String equipmentNumber;// 试验机ID
    private String equipmentName;// 试验机名称
    private String projectName;// 工程名称
    private String constructionSpot;// 施工部位
    private String testType;// 试验类型
    private String testId;// 试验id

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime testDate;// 试验日期
    private String concreteAge;// 龄期
    private String cubeArea;// 试件面积
    private String cubeCode;// 试件编号
    private Integer cubeCount;// 试块个数
    private String loadValue;//
    private String compressiveStrength;// 抗压强度
    private String representativeStrength;// 强度代表值
    private String designStrength;// 设计强度
    private Integer testEvaluation;// 评定结果 0合格，1不合格，2无效，3作废
    private String graphId;//
    private String processStress;//

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime insertTime;//
    private String isDeleted;// 删除标识(0,未删除,1.已删除)
    private String baseName;// 基地名称
    private String isQualified;// 合格1或者不合格0
    
    @TableField(exist = false)
    private String[] loadValueArray;
    
    @TableField(exist = false)
    private String[] compressiveStrengthArray;

    @TableField(exist = false)
    private JSONArray processStressArray;
    
    public String[] getLoadValueArray() {
        if(null == loadValue) {
            return new String[] {};
        }
        return loadValue.split(",");
    }
    
    public String[] getCompressiveStrengthArray() {
        if(null == compressiveStrength) {
            return new String[] {};
        }
        return compressiveStrength.split(",");
    }
    
    public JSONArray getProcessStressArray() {
        processStressArray = new JSONArray();
        if(null != processStress) {
            processStressArray = JSONArray.parseArray(processStress);
            String temp;
            for(int i=0,len=processStressArray.size();i<len;i++) {
                temp = processStressArray.getString(i);
                processStressArray.set(i, temp.split(","));
            }
        }
        return processStressArray;
    }

}
